package zjitc.interfa2.usb;

/**
 * @author:胡新雨
 * @date：2019/3/26 9:16
 */
public class Computer {
    /*类与类之间包含关系：作为属性*/
    Usb[] usbs;

    public Computer(){
        /*接口不能实例化（创建对象）*/
        usbs=new Usb[3];
    }
    public void add(Usb usb){
        for (int i=0;i<usbs.length;i++){
            if (usbs!=null){
                usbs[i]=usb;
            }
        }
    }
    public void powerOn(){
        for (int i=0;i<usbs.length;i++){
            if (usbs[i]!=null){
                usbs[i].trunOn();
            }
        }
        System.out.println("计算机开机成功！");
    }
    public void powerOff(){
        for (int i=0;i<usbs.length;i++){
            if (usbs[i]!=null){
                usbs[i].trunOff();
            }
        }
        System.out.println("计算机关机成功！");
    }
  /**  Mic mic; Usb usb;
    KeyBoard keyBoard;
    Mouse mouse;
   Computer(){

   }
    void trunOn(){
        mouse.trunOn();
        keyBoard.trunOn();
        mic.trunOn();
        System.out.println("计算机开机成功");
    }


    public void trunoff(){
        mouse.trunOff();
        keyBoard.trunOff();
        mic.trunOff();
        System.out.println("计算机关机成功");
    }*/
}
